package net.begincode.blog.controller;


import net.begincode.biz.KeyWordsBiz;
import net.begincode.blog.bean.vo.HotKeyWord;
import net.begincode.common.ApiResponse;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/***
 * 关键字
 */
@Controller
@RequestMapping("blog/keyword")
public class KeyWordController {

    @Resource
    private KeyWordsBiz keyWordsBiz;
    @RequestMapping(value = "/hotKey", method = RequestMethod.POST)
    @ResponseBody
    public ApiResponse<List<HotKeyWord>> queryRecommend(){
        List<HotKeyWord> hotKeyWords =  keyWordsBiz.queryHotKeyWord(10);
        if(CollectionUtils.isEmpty(hotKeyWords)){
            return ApiResponse.fail("没有推荐关键词");
        }
        return ApiResponse.success(hotKeyWords);
    }
}
